package com.xique.park.controller.app;

import com.xique.common.core.web.domain.AjaxResult;
import com.xique.common.log.annotation.Log;
import com.xique.common.log.enums.BusinessType;
import com.xique.park.bean.request.comm.*;
import com.xique.park.service.biz.service.IParkOnBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 在场记录controller
 */
@RestController
@RequestMapping("/app/parkOn")
public class AppParkOnController {

    @Autowired
    private IParkOnBizService parkOnBizService;

    /**
     * 查询在场记录列表
     * @param request
     * @return
     */
    @PostMapping("/list")
//    @PreAuthorize(hasPermi = "park:parkOn:list")
    public AjaxResult parkOnList(@Validated @RequestBody ParkOnListRequest request)
    {
        return parkOnBizService.getParkOnLst(request);
    }

    /**
     * 查询剩余车位信息
     * @return
     */
    @GetMapping("/getSpacesInfo")
//    @PreAuthorize(hasPermi = "park:parkOn:list")
    public AjaxResult getSpacesInfo()
    {
        return parkOnBizService.getSpacesInfo();
    }

    /**
     * 修改车牌信息回显
     * @param request
     * @return
     */
    @PostMapping("/getPlateInfo")
    //    @PreAuthorize(hasPermi = "park:parkOn:query")
    public AjaxResult getParkOnEditPlateInfo(@Validated @RequestBody EditParkOnRequest request){
        return parkOnBizService.getParkOnEditPlateInfo(request);
    }

    /**
     * 修改车牌信息保存
     * @param request
     * @return
     */
    @PostMapping("/editPlateInfo")
    @Log(title = "在场记录车牌信息", businessType = BusinessType.UPDATE)
    //    @PreAuthorize(hasPermi = "park:parkOn:edit")
    public AjaxResult editPlateInfo(@Validated @RequestBody ParkOnEditPlateSaveRequest request){
        return parkOnBizService.editPlateInfo(request);
    }

    /**
     * 标记出场
     * @param request
     * @return
     */
    @PostMapping("/markOut")
    @Log(title = "在场记录标记出场", businessType = BusinessType.DELETE)
    //    @PreAuthorize(hasPermi = "park:parkOn:remove")
    public AjaxResult markOut(@Validated @RequestBody MarkOutParkOnRequest request){
        return parkOnBizService.markOut(request);
    }
}
